﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using TMPro;
using UnityEngine;

public class BattleUIManager : MonoBehaviour
{
    public TextMeshProUGUI apCostText;
    public TextMeshProUGUI fpCostText;
    public TextMeshProUGUI drawCardNumText;
    public TextMeshProUGUI recycleCardNumText;

    public PlayerProxier playerProxier;
    
    private void Start()
    {
        BindListener();
    }

    private void Update()
    {
        if (playerProxier == null)
        {
            BindListener();
        }
    }

    public void BindListener()
    {
        playerProxier = GameObject.FindObjectOfType<PlayerProxier>();

        playerProxier.DrawCardNumListener += FlushDrawDeckCardNumText;
        playerProxier.RecycleCardNumListener += FlushRecycleCardNumText;
        playerProxier.APNumListener += FlushAPNumText;
        playerProxier.FPNumListener += FlushFPNumText;
        
        playerProxier.FlushAllUI();
    }
    
    public void FlushAPNumText(int num)
    {
        apCostText.SetText(num.ToString());
    }
    
    public void FlushFPNumText(int num)
    {
        fpCostText.SetText(num.ToString());
    }
    
    public void FlushDrawDeckCardNumText(int num)
    {
        drawCardNumText.SetText(num.ToString());
    }

    public void FlushRecycleCardNumText(int num)
    {
        recycleCardNumText.SetText(num.ToString());
    }
}
